<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
</head>
<script type="text/javascript">

function save(){
	var str_data=$("#templateinfo input").map(function(){
		   return ($(this).attr("name")+'='+$(this).val());
		 }).get().join("&") ;
    $.ajax({
        url:"${ctx}/template/saveTemplate",
        type: "POST",      
        dataType:"json",
        data: str_data,
        async: false,
        success: function(data) {
        	if(data.flag>0){
	            alert("保存成功！");	
	            //window.location.reload();
        	}
/* 	          $.each(data, function(index, element) {
             window.location.reload();
          }); */
        },
        error: function() {
          alert("error");
        }
      });
	
}

function  goBack(){
	//window.location.href='${ctx}/appFrameModule1/appFrameTradeMain?appid=${appid}'
	window.history.back(-1);
	//window.history.go(-2);
}

function  checkfile(){
	if($("#file").val()!=""){
		document.forms[0].submit();		
	}else{
	    alert("请上传文件！");
	}

}


function  changeValue(fileType){
	   document.getElementById("fileType").value=fileType;	
}
</script>

<body>
<div class="panel panel-default ">
   <div class="panel-heading">
      <h3 class="panel-title">
          创建模板
      </h3>
   </div>
   <div class="panel-body">
<form class="form-horizontal" role="form" id="templateinfo" name="baseinfo"  action="${pageContext.request.contextPath }/uploadTemplateFile/one" method="post"  enctype="multipart/form-data">
                  <br></br>
                        <div class="form-group">
<!--                           <label class="col-sm-2 control-label" for="templateId">模板标识</label>
                          <div class="col-sm-3">
                             <input class="form-control" id="templateId"  readonly="readonly" name="templateId"  type="text" />
                          </div> -->
                          <input class="form-control" id="templateId"   name="templateId"  type="hidden" value="${templateId}"/>
                          <label class="col-xs-2 control-label" for="fileType">文件类型</label>
                          <div class="col-xs-3">
                             <input class="form-control"   id="fileType" name="fileType"  type="hidden"  value="01" />
                             <select class="form-control"   id="file_Type" name="file_Type"  onclick="changeValue(this.value)">
	                             <option  value="01">H5文件</option>
	                             <option  value="02">JS文件</option>
	                             <option  value="03">JSP文件</option>
	                             <option  value="04">JAVA文件</option>
                             </select>
                          </div>                           
                       </div>
				   	   <div class="form-group">
					    <label for="file" class="col-xs-2 control-label">上传模板文件</label>
						<div class="col-xs-10">
						<input type="file" class="form-control" name="file" id="file"  >
					    </div>
					  </div> 

                    <br></br>

					<div class="form-group">
						<div class="col-xs-5"></div>
						<div class="col-xs-5">
							<button type="button" class="btn btn-default" onclick="checkfile()">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
							<button type="button" class="btn btn-default"  onclick="history.go(-1)">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>
						</div>
					</div>
                    <br></br>
                </form>
	</div>
	</div>
</body>
</html>